package 面试.新国都;

import java.util.Scanner;

/**
 * @author : K k
 * @date : 19:53 2020/10/14
 * 只能从左边或右边取字符
 * 然后组成最小字典序
 */
public class 最小字典序字符串 {
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        String str = in.nextLine();
        char[] s=str.toCharArray();
        StringBuilder sb=new StringBuilder();
        int low=0;
        int high=s.length-1;
        while (low <= high){
            //判断左右端点
            if (s[low]<s[high]){
                sb.append(s[low++]);
            }else if(s[low]>s[high]){
                sb.append(s[high--]);
            }else {
                //左右端点相同的情况 则比较后续一位来决定左右指针谁动
                sb.append(s[low]);
                int i=low+1;
                int j=high-1;
                while (i<=j){
                    if (s[i]<s[j]){
                        low++;
                        break;
                    }else if(s[i]>s[j]){
                        high--;
                        break;
                    }
                    i++;j--;
                }
                //说明两指针碰撞，两边的序列是相同的 可以随便取一个
                if (i>j)low++;
            }
        }
        System.out.println(sb.toString());
    }
}
